package com.gateway.enter.controller;

import com.gateway.enter.entity.Student;
import com.gateway.enter.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.Map;

/**
 * @author KLC0422
 * @create 2021-12-26- 11:02
 */
@Controller
public class ActiveController {

    @Autowired
    StudentService studentService;


    @GetMapping("/active")
    public String getActive(){
        return "site/activation";
    }
    @PostMapping("/active")
    public String active(Student student, String myPassword, Map<String,Object> map){
        if(myPassword.equals("wyklc2021")){
            student.setActive(1);
            studentService.updateStudentByActive(student);
            map.put("msg","激活成功");
        }
        else {
            map.put("msg","管理员密码不正确");
        };
        return "site/error";
    }
}
